<?php

declare(strict_types=1);

namespace app\admin\controller;

use app\admin\service\LogisticsOrder as  LogisticsOrderService;
use app\admin\validate\LogisticsOrder as LogisticsOrderValidate;
use think\Request;

class LogisticsOrder extends Base
{
    protected $request;
    protected $service;
    protected $validate;

    public function __construct(Request $request, LogisticsOrderService $service, LogisticsOrderValidate $validate)
    {
        $this->request = $request;
        $this->service = $service;
        $this->validate = $validate;
    }

    public function update()
    {
        $params = $this->request->params;
        if (!$this->validate->scene('update')->check($params)) {
            return $this->returnJsonData(100001, null, $this->validate->getError());
        }

        $res = $this->service->update($params);

        $code = $res['code'];
        $data = $res['data'] ?? [];
        $message = $res['message'] ?? "";
        return $this->returnJsonData($code, $data, $message);
    }
}
